home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / lispref.info-27.z / lispref.info-27
Encoding:
GNU Info File  |  1998-05-21  |  47.9 KB  |  1,130 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo version
  2. 1.68 from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
  12. Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
  13. Reference Manual (for 19.15 and 20.1, 20.2) v3.2, April, May 1997
  14.  
  15.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  16. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  17. Copyright (C) 1995, 1996 Ben Wing.
  18.  
  19.    Permission is granted to make and distribute verbatim copies of this
  20. manual provided the copyright notice and this permission notice are
  21. preserved on all copies.
  22.  
  23.    Permission is granted to copy and distribute modified versions of
  24. this manual under the conditions for verbatim copying, provided that the
  25. entire resulting derived work is distributed under the terms of a
  26. permission notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that this permission notice may be stated in a
  31. translation approved by the Foundation.
  32.  
  33.    Permission is granted to copy and distribute modified versions of
  34. this manual under the conditions for verbatim copying, provided also
  35. that the section entitled "GNU General Public License" is included
  36. exactly as in the original, and provided that the entire resulting
  37. derived work is distributed under the terms of a permission notice
  38. identical to this one.
  39.  
  40.    Permission is granted to copy and distribute translations of this
  41. manual into another language, under the above conditions for modified
  42. versions, except that the section entitled "GNU General Public License"
  43. may be included in a translation approved by the Free Software
  44. Foundation instead of in the original English.
  45.  
  46. 
  47. File: lispref.info,  Node: Skipping Characters,  Prev: List Motion,  Up: Motion
  48.  
  49. Skipping Characters
  50. -------------------
  51.  
  52.    The following two functions move point over a specified set of
  53. characters.  For example, they are often used to skip whitespace.  For
  54. related functions, see *Note Motion and Syntax::.
  55.  
  56.  - Function: skip-chars-forward CHARACTER-SET &optional LIMIT BUFFER
  57.      This function moves point in BUFFER forward, skipping over a given
  58.      set of characters.  It examines the character following point,
  59.      then advances point if the character matches CHARACTER-SET.  This
  60.      continues until it reaches a character that does not match.  The
  61.      function returns `nil'.  BUFFER defaults to the current buffer if
  62.      omitted.
  63.  
  64.      The argument CHARACTER-SET is like the inside of a `[...]' in a
  65.      regular expression except that `]' is never special and `\' quotes
  66.      `^', `-' or `\'.  Thus, `"a-zA-Z"' skips over all letters,
  67.      stopping before the first non-letter, and `"^a-zA-Z'" skips
  68.      non-letters stopping before the first letter.  *Note Regular
  69.      Expressions::.
  70.  
  71.      If LIMIT is supplied (it must be a number or a marker), it
  72.      specifies the maximum position in the buffer that point can be
  73.      skipped to.  Point will stop at or before LIMIT.
  74.  
  75.      In the following example, point is initially located directly
  76.      before the `T'.  After the form is evaluated, point is located at
  77.      the end of that line (between the `t' of `hat' and the newline).
  78.      The function skips all letters and spaces, but not newlines.
  79.  
  80.           ---------- Buffer: foo ----------
  81.           I read "-!-The cat in the hat
  82.           comes back" twice.
  83.           ---------- Buffer: foo ----------
  84.           
  85.           (skip-chars-forward "a-zA-Z ")
  86.                => nil
  87.           
  88.           ---------- Buffer: foo ----------
  89.           I read "The cat in the hat-!-
  90.           comes back" twice.
  91.           ---------- Buffer: foo ----------
  92.  
  93.  - Function: skip-chars-backward CHARACTER-SET &optional LIMIT BUFFER
  94.      This function moves point backward, skipping characters that match
  95.      CHARACTER-SET, until LIMIT.  It just like `skip-chars-forward'
  96.      except for the direction of motion.
  97.  
  98. 
  99. File: lispref.info,  Node: Excursions,  Next: Narrowing,  Prev: Motion,  Up: Positions
  100.  
  101. Excursions
  102. ==========
  103.  
  104.    It is often useful to move point "temporarily" within a localized
  105. portion of the program, or to switch buffers temporarily.  This is
  106. called an "excursion", and it is done with the `save-excursion' special
  107. form.  This construct saves the current buffer and its values of point
  108. and the mark so they can be restored after the completion of the
  109. excursion.
  110.  
  111.    The forms for saving and restoring the configuration of windows are
  112. described elsewhere (see *Note Window Configurations:: and *note Frame
  113. Configurations::.).
  114.  
  115.  - Special Form: save-excursion FORMS...
  116.      The `save-excursion' special form saves the identity of the current
  117.      buffer and the values of point and the mark in it, evaluates
  118.      FORMS, and finally restores the buffer and its saved values of
  119.      point and the mark.  All three saved values are restored even in
  120.      case of an abnormal exit via `throw' or error (*note Nonlocal
  121.      Exits::.).
  122.  
  123.      The `save-excursion' special form is the standard way to switch
  124.      buffers or move point within one part of a program and avoid
  125.      affecting the rest of the program.  It is used more than 500 times
  126.      in the Lisp sources of XEmacs.
  127.  
  128.      `save-excursion' does not save the values of point and the mark for
  129.      other buffers, so changes in other buffers remain in effect after
  130.      `save-excursion' exits.
  131.  
  132.      Likewise, `save-excursion' does not restore window-buffer
  133.      correspondences altered by functions such as `switch-to-buffer'.
  134.      One way to restore these correspondences, and the selected window,
  135.      is to use `save-window-excursion' inside `save-excursion' (*note
  136.      Window Configurations::.).
  137.  
  138.      The value returned by `save-excursion' is the result of the last of
  139.      FORMS, or `nil' if no FORMS are given.
  140.  
  141.           (save-excursion
  142.             FORMS)
  143.           ==
  144.           (let ((old-buf (current-buffer))
  145.                 (old-pnt (point-marker))
  146.                 (old-mark (copy-marker (mark-marker))))
  147.             (unwind-protect
  148.                 (progn FORMS)
  149.               (set-buffer old-buf)
  150.               (goto-char old-pnt)
  151.               (set-marker (mark-marker) old-mark)))
  152.  
  153.  - Special Form: save-current-buffer FORMS...
  154.      This special form is similar to `save-excursion' but it only saves
  155.      and restores the current buffer.
  156.  
  157.  - Special Form: save-selected-window FORMS...
  158.      This special form is similar to `save-excursion' but it saves and
  159.      restores the selected window and nothing else.
  160.  
  161. 
  162. File: lispref.info,  Node: Narrowing,  Prev: Excursions,  Up: Positions
  163.  
  164. Narrowing
  165. =========
  166.  
  167.    "Narrowing" means limiting the text addressable by XEmacs editing
  168. commands to a limited range of characters in a buffer.  The text that
  169. remains addressable is called the "accessible portion" of the buffer.
  170.  
  171.    Narrowing is specified with two buffer positions which become the
  172. beginning and end of the accessible portion.  For most editing commands
  173. and most Emacs primitives, these positions replace the values of the
  174. beginning and end of the buffer.  While narrowing is in effect, no text
  175. outside the accessible portion is displayed, and point cannot move
  176. outside the accessible portion.
  177.  
  178.    Values such as positions or line numbers, which usually count from
  179. the beginning of the buffer, do so despite narrowing, but the functions
  180. which use them refuse to operate on text that is inaccessible.
  181.  
  182.    The commands for saving buffers are unaffected by narrowing; they
  183. save the entire buffer regardless of any narrowing.
  184.  
  185.  - Command: narrow-to-region START END &optional BUFFER
  186.      This function sets the accessible portion of BUFFER to start at
  187.      START and end at END.  Both arguments should be character
  188.      positions.  BUFFER defaults to the current buffer if omitted.
  189.  
  190.      In an interactive call, START and END are set to the bounds of the
  191.      current region (point and the mark, with the smallest first).
  192.  
  193.  - Command: narrow-to-page &optional MOVE-COUNT
  194.      This function sets the accessible portion of the current buffer to
  195.      include just the current page.  An optional first argument
  196.      MOVE-COUNT non-`nil' means to move forward or backward by
  197.      MOVE-COUNT pages and then narrow.  The variable `page-delimiter'
  198.      specifies where pages start and end (*note Standard Regexps::.).
  199.  
  200.      In an interactive call, MOVE-COUNT is set to the numeric prefix
  201.      argument.
  202.  
  203.  - Command: widen &optional BUFFER
  204.      This function cancels any narrowing in BUFFER, so that the entire
  205.      contents are accessible.  This is called "widening".  It is
  206.      equivalent to the following expression:
  207.  
  208.           (narrow-to-region 1 (1+ (buffer-size)))
  209.  
  210.      BUFFER defaults to the current buffer if omitted.
  211.  
  212.  - Special Form: save-restriction BODY...
  213.      This special form saves the current bounds of the accessible
  214.      portion, evaluates the BODY forms, and finally restores the saved
  215.      bounds, thus restoring the same state of narrowing (or absence
  216.      thereof) formerly in effect.  The state of narrowing is restored
  217.      even in the event of an abnormal exit via `throw' or error (*note
  218.      Nonlocal Exits::.).  Therefore, this construct is a clean way to
  219.      narrow a buffer temporarily.
  220.  
  221.      The value returned by `save-restriction' is that returned by the
  222.      last form in BODY, or `nil' if no body forms were given.
  223.  
  224.      *Caution:* it is easy to make a mistake when using the
  225.      `save-restriction' construct.  Read the entire description here
  226.      before you try it.
  227.  
  228.      If BODY changes the current buffer, `save-restriction' still
  229.      restores the restrictions on the original buffer (the buffer whose
  230.      restructions it saved from), but it does not restore the identity
  231.      of the current buffer.
  232.  
  233.      `save-restriction' does *not* restore point and the mark; use
  234.      `save-excursion' for that.  If you use both `save-restriction' and
  235.      `save-excursion' together, `save-excursion' should come first (on
  236.      the outside).  Otherwise, the old point value would be restored
  237.      with temporary narrowing still in effect.  If the old point value
  238.      were outside the limits of the temporary narrowing, this would
  239.      fail to restore it accurately.
  240.  
  241.      The `save-restriction' special form records the values of the
  242.      beginning and end of the accessible portion as distances from the
  243.      beginning and end of the buffer.  In other words, it records the
  244.      amount of inaccessible text before and after the accessible
  245.      portion.
  246.  
  247.      This method yields correct results if BODY does further narrowing.
  248.      However, `save-restriction' can become confused if the body widens
  249.      and then make changes outside the range of the saved narrowing.
  250.      When this is what you want to do, `save-restriction' is not the
  251.      right tool for the job.  Here is what you must use instead:
  252.  
  253.           (let ((beg (point-min-marker))
  254.                 (end (point-max-marker)))
  255.             (unwind-protect
  256.                 (progn BODY)
  257.               (save-excursion
  258.                 (set-buffer (marker-buffer beg))
  259.                 (narrow-to-region beg end))))
  260.  
  261.      Here is a simple example of correct use of `save-restriction':
  262.  
  263.           ---------- Buffer: foo ----------
  264.           This is the contents of foo
  265.           This is the contents of foo
  266.           This is the contents of foo-!-
  267.           ---------- Buffer: foo ----------
  268.           
  269.           (save-excursion
  270.             (save-restriction
  271.               (goto-char 1)
  272.               (forward-line 2)
  273.               (narrow-to-region 1 (point))
  274.               (goto-char (point-min))
  275.               (replace-string "foo" "bar")))
  276.           
  277.           ---------- Buffer: foo ----------
  278.           This is the contents of bar
  279.           This is the contents of bar
  280.           This is the contents of foo-!-
  281.           ---------- Buffer: foo ----------
  282.  
  283. 
  284. File: lispref.info,  Node: Markers,  Next: Text,  Prev: Positions,  Up: Top
  285.  
  286. Markers
  287. *******
  288.  
  289.    A "marker" is a Lisp object used to specify a position in a buffer
  290. relative to the surrounding text.  A marker changes its offset from the
  291. beginning of the buffer automatically whenever text is inserted or
  292. deleted, so that it stays with the two characters on either side of it.
  293.  
  294. * Menu:
  295.  
  296. * Overview of Markers::      The components of a marker, and how it relocates.
  297. * Predicates on Markers::    Testing whether an object is a marker.
  298. * Creating Markers::         Making empty markers or markers at certain places.
  299. * Information from Markers:: Finding the marker's buffer or character position.
  300. * Changing Markers::         Moving the marker to a new buffer or position.
  301. * The Mark::                 How "the mark" is implemented with a marker.
  302. * The Region::               How to access "the region".
  303.  
  304. 
  305. File: lispref.info,  Node: Overview of Markers,  Next: Predicates on Markers,  Up: Markers
  306.  
  307. Overview of Markers
  308. ===================
  309.  
  310.    A marker specifies a buffer and a position in that buffer.  The
  311. marker can be used to represent a position in the functions that
  312. require one, just as an integer could be used.  *Note Positions::, for
  313. a complete description of positions.
  314.  
  315.    A marker has two attributes: the marker position, and the marker
  316. buffer.  The marker position is an integer that is equivalent (at a
  317. given time) to the marker as a position in that buffer.  But the
  318. marker's position value can change often during the life of the marker.
  319. Insertion and deletion of text in the buffer relocate the marker.  The
  320. idea is that a marker positioned between two characters remains between
  321. those two characters despite insertion and deletion elsewhere in the
  322. buffer.  Relocation changes the integer equivalent of the marker.
  323.  
  324.    Deleting text around a marker's position leaves the marker between
  325. the characters immediately before and after the deleted text.  Inserting
  326. text at the position of a marker normally leaves the marker in front of
  327. the new text--unless it is inserted with `insert-before-markers' (*note
  328. Insertion::.).
  329.  
  330.    Insertion and deletion in a buffer must check all the markers and
  331. relocate them if necessary.  This slows processing in a buffer with a
  332. large number of markers.  For this reason, it is a good idea to make a
  333. marker point nowhere if you are sure you don't need it any more.
  334. Unreferenced markers are garbage collected eventually, but until then
  335. will continue to use time if they do point somewhere.
  336.  
  337.    Because it is common to perform arithmetic operations on a marker
  338. position, most of the arithmetic operations (including `+' and `-')
  339. accept markers as arguments.  In such cases, the marker stands for its
  340. current position.
  341.  
  342.    Note that you can use extents to achieve the same functionality, and
  343. more, as markers. (Markers were defined before extents, which is why
  344. they both continue to exist.) A zero-length extent with the
  345. `detachable' property removed is almost identical to a marker.  (*Note
  346. Extent Endpoints::, for more information on zero-length extents.)
  347.  
  348.    In particular:
  349.  
  350.    * In order to get marker-like behavior in a zero-length extent, the
  351.      `detachable' property must be removed (otherwise, the extent will
  352.      disappear when text near it is deleted) and exactly one endpoint
  353.      must be closed (if both endpoints are closed, the extent will
  354.      expand to contain text inserted where it is located).
  355.  
  356.    * If a zero-length extent has the `end-open' property but not the
  357.      `start-open' property (this is the default), text inserted at the
  358.      extent's location causes the extent to move forward, just like a
  359.      marker.
  360.  
  361.    * If a zero-length extent has the `start-open' property but not the
  362.      `end-open' property, text inserted at the extent's location causes
  363.      the extent to remain before the text, like what happens to markers
  364.      when `insert-before-markers' is used.
  365.  
  366.    * Markers end up after or before inserted text depending on whether
  367.      `insert' or `insert-before-markers' was called.  These functions
  368.      do not affect zero-length extents differently; instead, the
  369.      presence or absence of the `start-open' and `end-open' extent
  370.      properties determines this, as just described.
  371.  
  372.    * Markers are automatically removed from a buffer when they are no
  373.      longer in use.  Extents remain around until explicitly removed
  374.      from a buffer.
  375.  
  376.    * Many functions are provided for listing the extents in a buffer or
  377.      in a region of a buffer.  No such functions exist for markers.
  378.  
  379.    Here are examples of creating markers, setting markers, and moving
  380. point to markers:
  381.  
  382.      ;; Make a new marker that initially does not point anywhere:
  383.      (setq m1 (make-marker))
  384.           => #<marker in no buffer>
  385.      
  386.      ;; Set `m1' to point between the 99th and 100th characters
  387.      ;;   in the current buffer:
  388.      (set-marker m1 100)
  389.           => #<marker at 100 in markers.texi>
  390.      
  391.      ;; Now insert one character at the beginning of the buffer:
  392.      (goto-char (point-min))
  393.           => 1
  394.      (insert "Q")
  395.           => nil
  396.      
  397.      ;; `m1' is updated appropriately.
  398.      m1
  399.           => #<marker at 101 in markers.texi>
  400.      
  401.      ;; Two markers that point to the same position
  402.      ;;   are not `eq', but they are `equal'.
  403.      (setq m2 (copy-marker m1))
  404.           => #<marker at 101 in markers.texi>
  405.      (eq m1 m2)
  406.           => nil
  407.      (equal m1 m2)
  408.           => t
  409.      
  410.      ;; When you are finished using a marker, make it point nowhere.
  411.      (set-marker m1 nil)
  412.           => #<marker in no buffer>
  413.  
  414. 
  415. File: lispref.info,  Node: Predicates on Markers,  Next: Creating Markers,  Prev: Overview of Markers,  Up: Markers
  416.  
  417. Predicates on Markers
  418. =====================
  419.  
  420.    You can test an object to see whether it is a marker, or whether it
  421. is either an integer or a marker or either an integer, a character, or a
  422. marker.  The latter tests are useful in connection with the arithmetic
  423. functions that work with any of markers, integers, or characters.
  424.  
  425.  - Function: markerp OBJECT
  426.      This function returns `t' if OBJECT is a marker, `nil' otherwise.
  427.      Note that integers are not markers, even though many functions
  428.      will accept either a marker or an integer.
  429.  
  430.  - Function: integer-or-marker-p OBJECT
  431.      This function returns `t' if OBJECT is an integer or a marker,
  432.      `nil' otherwise.
  433.  
  434.  - Function: integer-char-or-marker-p OBJECT
  435.      This function returns `t' if OBJECT is an integer, a character, or
  436.      a marker, `nil' otherwise.
  437.  
  438.  - Function: number-or-marker-p OBJECT
  439.      This function returns `t' if OBJECT is a number (either kind) or a
  440.      marker, `nil' otherwise.
  441.  
  442.  - Function: number-char-or-marker-p OBJECT
  443.      This function returns `t' if OBJECT is a number (either kind), a
  444.      character, or a marker, `nil' otherwise.
  445.  
  446. 
  447. File: lispref.info,  Node: Creating Markers,  Next: Information from Markers,  Prev: Predicates on Markers,  Up: Markers
  448.  
  449. Functions That Create Markers
  450. =============================
  451.  
  452.    When you create a new marker, you can make it point nowhere, or point
  453. to the present position of point, or to the beginning or end of the
  454. accessible portion of the buffer, or to the same place as another given
  455. marker.
  456.  
  457.  - Function: make-marker
  458.      This functions returns a newly created marker that does not point
  459.      anywhere.
  460.  
  461.           (make-marker)
  462.                => #<marker in no buffer>
  463.  
  464.  - Function: point-marker &optional DONT-COPY-P BUFFER
  465.      This function returns a marker that points to the present position
  466.      of point in BUFFER, which defaults to the current buffer.  *Note
  467.      Point::.  For an example, see `copy-marker', below.
  468.  
  469.      Internally, a marker corresponding to point is always maintained.
  470.      Normally the marker returned by `point-marker' is a copy; you may
  471.      modify it with reckless abandon.  However, if optional argument
  472.      DONT-COPY-P is non-`nil', then the real point-marker is returned;
  473.      modifying the position of this marker will move point.  It is
  474.      illegal to change the buffer of it, or make it point nowhere.
  475.  
  476.  - Function: point-min-marker &optional BUFFER
  477.      This function returns a new marker that points to the beginning of
  478.      the accessible portion of BUFFER, which defaults to the current
  479.      buffer.  This will be the beginning of the buffer unless narrowing
  480.      is in effect.  *Note Narrowing::.
  481.  
  482.  - Function: point-max-marker &optional BUFFER
  483.      This function returns a new marker that points to the end of the
  484.      accessible portion of BUFFER, which defaults to the current
  485.      buffer.  This will be the end of the buffer unless narrowing is in
  486.      effect.  *Note Narrowing::.
  487.  
  488.      Here are examples of this function and `point-min-marker', shown in
  489.      a buffer containing a version of the source file for the text of
  490.      this chapter.
  491.  
  492.           (point-min-marker)
  493.                => #<marker at 1 in markers.texi>
  494.           (point-max-marker)
  495.                => #<marker at 15573 in markers.texi>
  496.           
  497.           (narrow-to-region 100 200)
  498.                => nil
  499.           (point-min-marker)
  500.                => #<marker at 100 in markers.texi>
  501.           (point-max-marker)
  502.                => #<marker at 200 in markers.texi>
  503.  
  504.  - Function: copy-marker MARKER-OR-INTEGER
  505.      If passed a marker as its argument, `copy-marker' returns a new
  506.      marker that points to the same place and the same buffer as does
  507.      MARKER-OR-INTEGER.  If passed an integer as its argument,
  508.      `copy-marker' returns a new marker that points to position
  509.      MARKER-OR-INTEGER in the current buffer.
  510.  
  511.      If passed an integer argument less than 1, `copy-marker' returns a
  512.      new marker that points to the beginning of the current buffer.  If
  513.      passed an integer argument greater than the length of the buffer,
  514.      `copy-marker' returns a new marker that points to the end of the
  515.      buffer.
  516.  
  517.      An error is signaled if MARKER is neither a marker nor an integer.
  518.  
  519.           (setq p (point-marker))
  520.                => #<marker at 2139 in markers.texi>
  521.           
  522.           (setq q (copy-marker p))
  523.                => #<marker at 2139 in markers.texi>
  524.           
  525.           (eq p q)
  526.                => nil
  527.           
  528.           (equal p q)
  529.                => t
  530.           
  531.           (point)
  532.                => 2139
  533.           
  534.           (set-marker p 3000)
  535.                => #<marker at 3000 in markers.texi>
  536.           
  537.           (point)
  538.                => 2139
  539.           
  540.           (setq p (point-marker t))
  541.                => #<marker at 2139 in markers.texi>
  542.           
  543.           (set-marker p 3000)
  544.                => #<marker at 3000 in markers.texi>
  545.           
  546.           (point)
  547.                => 3000
  548.           
  549.           (copy-marker 0)
  550.                => #<marker at 1 in markers.texi>
  551.           
  552.           (copy-marker 20000)
  553.                => #<marker at 7572 in markers.texi>
  554.  
  555. 
  556. File: lispref.info,  Node: Information from Markers,  Next: Changing Markers,  Prev: Creating Markers,  Up: Markers
  557.  
  558. Information from Markers
  559. ========================
  560.  
  561.    This section describes the functions for accessing the components of
  562. a marker object.
  563.  
  564.  - Function: marker-position MARKER
  565.      This function returns the position that MARKER points to, or `nil'
  566.      if it points nowhere.
  567.  
  568.  - Function: marker-buffer MARKER
  569.      This function returns the buffer that MARKER points into, or `nil'
  570.      if it points nowhere.
  571.  
  572.           (setq m (make-marker))
  573.                => #<marker in no buffer>
  574.           (marker-position m)
  575.                => nil
  576.           (marker-buffer m)
  577.                => nil
  578.           
  579.           (set-marker m 3770 (current-buffer))
  580.                => #<marker at 3770 in markers.texi>
  581.           (marker-buffer m)
  582.                => #<buffer markers.texi>
  583.           (marker-position m)
  584.                => 3770
  585.  
  586.    Two distinct markers are considered `equal' (even though not `eq')
  587. to each other if they have the same position and buffer, or if they
  588. both point nowhere.
  589.  
  590. 
  591. File: lispref.info,  Node: Changing Markers,  Next: The Mark,  Prev: Information from Markers,  Up: Markers
  592.  
  593. Changing Marker Positions
  594. =========================
  595.  
  596.    This section describes how to change the position of an existing
  597. marker.  When you do this, be sure you know whether the marker is used
  598. outside of your program, and, if so, what effects will result from
  599. moving it--otherwise, confusing things may happen in other parts of
  600. Emacs.
  601.  
  602.  - Function: set-marker MARKER POSITION &optional BUFFER
  603.      This function moves MARKER to POSITION in BUFFER.  If BUFFER is
  604.      not provided, it defaults to the current buffer.
  605.  
  606.      If POSITION is less than 1, `set-marker' moves MARKER to the
  607.      beginning of the buffer.  If POSITION is greater than the size of
  608.      the buffer, `set-marker' moves marker to the end of the buffer.
  609.      If POSITION is `nil' or a marker that points nowhere, then MARKER
  610.      is set to point nowhere.
  611.  
  612.      The value returned is MARKER.
  613.  
  614.           (setq m (point-marker))
  615.                => #<marker at 4714 in markers.texi>
  616.           (set-marker m 55)
  617.                => #<marker at 55 in markers.texi>
  618.           (setq b (get-buffer "foo"))
  619.                => #<buffer foo>
  620.           (set-marker m 0 b)
  621.                => #<marker at 1 in foo>
  622.  
  623.  - Function: move-marker MARKER POSITION &optional BUFFER
  624.      This is another name for `set-marker'.
  625.  
  626. 
  627. File: lispref.info,  Node: The Mark,  Next: The Region,  Prev: Changing Markers,  Up: Markers
  628.  
  629. The Mark
  630. ========
  631.  
  632.    One special marker in each buffer is designated "the mark".  It
  633. records a position for the user for the sake of commands such as `C-w'
  634. and `C-x <TAB>'.  Lisp programs should set the mark only to values that
  635. have a potential use to the user, and never for their own internal
  636. purposes.  For example, the `replace-regexp' command sets the mark to
  637. the value of point before doing any replacements, because this enables
  638. the user to move back there conveniently after the replace is finished.
  639.  
  640.    Once the mark "exists" in a buffer, it normally never ceases to
  641. exist.  However, it may become "inactive", and usually does so after
  642. each command (other than simple motion commands and some commands that
  643. explicitly activate the mark).  When the mark is active, the region
  644. between point and the mark is called the "active region" and is
  645. highlighted specially.
  646.  
  647.    Many commands are designed so that when called interactively they
  648. operate on the text between point and the mark.  Such commands work
  649. only when an active region exists, i.e. when the mark is active.  (The
  650. reason for this is to prevent you from accidentally deleting or
  651. changing large chunks of your text.) If you are writing such a command,
  652. don't examine the mark directly; instead, use `interactive' with the
  653. `r' specification.  This provides the values of point and the mark as
  654. arguments to the command in an interactive call, but permits other Lisp
  655. programs to specify arguments explicitly, and automatically signals an
  656. error if the command is called interactively when no active region
  657. exists.  *Note Interactive Codes::.
  658.  
  659.    Each buffer has its own value of the mark that is independent of the
  660. value of the mark in other buffers. (When a buffer is created, the mark
  661. exists but does not point anywhere.  We consider this state as "the
  662. absence of a mark in that buffer.") However, only one active region can
  663. exist at a time.  Activating the mark in one buffer automatically
  664. deactivates an active mark in any other buffer.  Note that the user can
  665. explicitly activate a mark at any time by using the command
  666. `activate-region' (normally bound to `M-C-z') or by using the command
  667. `exchange-point-and-mark' (normally bound to `C-x C-x'), which has the
  668. side effect of activating the mark.
  669.  
  670.    Some people do not like active regions, so they disable this behavior
  671. by setting the variable `zmacs-regions' to `nil'.  This makes the mark
  672. always active (except when a buffer is just created and the mark points
  673. nowhere), and turns off the highlighting of the region between point
  674. and the mark.  Commands that explicitly retrieve the value of the mark
  675. should make sure that they behave correctly and consistently
  676. irrespective of the setting of `zmacs-regions'; some primitives are
  677. provided to ensure this behavior.
  678.  
  679.    In addition to the mark, each buffer has a "mark ring" which is a
  680. list of markers containing previous values of the mark.  When editing
  681. commands change the mark, they should normally save the old value of the
  682. mark on the mark ring.  The variable `mark-ring-max' specifies the
  683. maximum number of entries in the mark ring; once the list becomes this
  684. long, adding a new element deletes the last element.
  685.  
  686.  - Function: mark &optional FORCE BUFFER
  687.      This function returns BUFFER's mark position as an integer.
  688.      BUFFER defaults to the current buffer if omitted.
  689.  
  690.      If the mark is inactive, `mark' normally returns `nil'.  However,
  691.      if FORCE is non-`nil', then `mark' returns the mark position
  692.      anyway--or `nil', if the mark is not yet set for the buffer.
  693.  
  694.      (Remember that if ZMACS-REGIONS is `nil', the mark is always
  695.      active as long as it exists, and the FORCE argument will have no
  696.      effect.)
  697.  
  698.      If you are using this in an editing command, you are most likely
  699.      making a mistake; see the documentation of `set-mark' below.
  700.  
  701.  - Function: mark-marker INACTIVE-P BUFFER
  702.      This function returns BUFFER's mark.  BUFFER defaults to the
  703.      current buffer if omitted.  This is the very marker that records
  704.      the mark location inside XEmacs, not a copy.  Therefore, changing
  705.      this marker's position will directly affect the position of the
  706.      mark.  Don't do it unless that is the effect you want.
  707.  
  708.      If the mark is inactive, `mark-marker' normally returns `nil'.
  709.      However, if FORCE is non-`nil', then `mark-marker' returns the
  710.      mark anyway.
  711.           (setq m (mark-marker))
  712.                => #<marker at 3420 in markers.texi>
  713.           (set-marker m 100)
  714.                => #<marker at 100 in markers.texi>
  715.           (mark-marker)
  716.                => #<marker at 100 in markers.texi>
  717.  
  718.      Like any marker, this marker can be set to point at any buffer you
  719.      like.  We don't recommend that you make it point at any buffer
  720.      other than the one of which it is the mark.  If you do, it will
  721.      yield perfectly consistent, but rather odd, results.
  722.  
  723.  - Function: set-mark POSITION &optional BUFFER
  724.      This function sets `buffer''s mark to POSITION, and activates the
  725.      mark.  BUFFER defaults to the current buffer if omitted.  The old
  726.      value of the mark is *not* pushed onto the mark ring.
  727.  
  728.      *Please note:* Use this function only if you want the user to see
  729.      that the mark has moved, and you want the previous mark position to
  730.      be lost.  Normally, when a new mark is set, the old one should go
  731.      on the `mark-ring'.  For this reason, most applications should use
  732.      `push-mark' and `pop-mark', not `set-mark'.
  733.  
  734.      Novice XEmacs Lisp programmers often try to use the mark for the
  735.      wrong purposes.  The mark saves a location for the user's
  736.      convenience.  An editing command should not alter the mark unless
  737.      altering the mark is part of the user-level functionality of the
  738.      command.  (And, in that case, this effect should be documented.)
  739.      To remember a location for internal use in the Lisp program, store
  740.      it in a Lisp variable.  For example:
  741.  
  742.           (let ((beg (point)))
  743.             (forward-line 1)
  744.             (delete-region beg (point))).
  745.  
  746.  - Command: exchange-point-and-mark &optional DONT-ACTIVATE-REGION
  747.      This function exchanges the positions of point and the mark.  It
  748.      is intended for interactive use.  The mark is also activated
  749.      unless DONT-ACTIVATE-REGION is non-`nil'.
  750.  
  751.  - Function: push-mark &optional POSITION NOMSG ACTIVATE BUFFER
  752.      This function sets BUFFER's mark to POSITION, and pushes a copy of
  753.      the previous mark onto `mark-ring'.  BUFFER defaults to the
  754.      current buffer if omitted.  If POSITION is `nil', then the value
  755.      of point is used.  `push-mark' returns `nil'.
  756.  
  757.      If the last global mark pushed was not in BUFFER, also push
  758.      POSITION on the global mark ring (see below).
  759.  
  760.      The function `push-mark' normally *does not* activate the mark.
  761.      To do that, specify `t' for the argument ACTIVATE.
  762.  
  763.      A `Mark set' message is displayed unless NOMSG is non-`nil'.
  764.  
  765.  - Function: pop-mark
  766.      This function pops off the top element of `mark-ring' and makes
  767.      that mark become the buffer's actual mark.  This does not move
  768.      point in the buffer, and it does nothing if `mark-ring' is empty.
  769.      It deactivates the mark.
  770.  
  771.      The return value is not meaningful.
  772.  
  773.  - Variable: mark-ring
  774.      The value of this buffer-local variable is the list of saved former
  775.      marks of the current buffer, most recent first.
  776.  
  777.           mark-ring
  778.           => (#<marker at 11050 in markers.texi>
  779.               #<marker at 10832 in markers.texi>
  780.               ...)
  781.  
  782.  - User Option: mark-ring-max
  783.      The value of this variable is the maximum size of `mark-ring'.  If
  784.      more marks than this are pushed onto the `mark-ring', `push-mark'
  785.      discards an old mark when it adds a new one.
  786.  
  787.    In additional to a per-buffer mark ring, there is a "global mark
  788. ring".  Marks are pushed onto the global mark ring the first time you
  789. set a mark after switching buffers.
  790.  
  791.  - Variable: global-mark-ring
  792.      The value of this variable is the list of saved former global
  793.      marks, most recent first.
  794.  
  795.  - User Option: mark-ring-max
  796.      The value of this variable is the maximum size of
  797.      `global-mark-ring'.  If more marks than this are pushed onto the
  798.      `global-mark-ring', `push-mark' discards an old mark when it adds
  799.      a new one.
  800.  
  801.  - Command: pop-global-mark
  802.      This function pops a mark off the global mark ring and jumps to
  803.      that location.
  804.  
  805. 
  806. File: lispref.info,  Node: The Region,  Prev: The Mark,  Up: Markers
  807.  
  808. The Region
  809. ==========
  810.  
  811.    The text between point and the mark is known as "the region".
  812. Various functions operate on text delimited by point and the mark, but
  813. only those functions specifically related to the region itself are
  814. described here.
  815.  
  816.    When `zmacs-regions' is non-`nil' (this is the default), the concept
  817. of an "active region" exists.  The region is active when the
  818. corresponding mark is active.  Note that only one active region at a
  819. time can exist - i.e. only one buffer's region is active at a time.
  820. *Note The Mark:: for more information about active regions.
  821.  
  822.  - User Option: zmacs-regions
  823.      If non-`nil' (the default), active regions are used.  *Note The
  824.      Mark::, for a detailed explanation of what this means.
  825.  
  826.    A number of functions are provided for explicitly determining the
  827. bounds of the region and whether it is active.  Few programs need to use
  828. these functions, however.  A command designed to operate on a region
  829. should normally use `interactive' with the `r' specification to find
  830. the beginning and end of the region.  This lets other Lisp programs
  831. specify the bounds explicitly as arguments and automatically respects
  832. the user's setting for ZMACS-REGIONS.  (*Note Interactive Codes::.)
  833.  
  834.  - Function: region-beginning &optional BUFFER
  835.      This function returns the position of the beginning of BUFFER's
  836.      region (as an integer).  This is the position of either point or
  837.      the mark, whichever is smaller.  BUFFER defaults to the current
  838.      buffer if omitted.
  839.  
  840.      If the mark does not point anywhere, an error is signaled.  Note
  841.      that this function ignores whether the region is active.
  842.  
  843.  - Function: region-end &optional BUFFER
  844.      This function returns the position of the end of BUFFER's region
  845.      (as an integer).  This is the position of either point or the mark,
  846.      whichever is larger.  BUFFER defaults to the current buffer if
  847.      omitted.
  848.  
  849.      If the mark does not point anywhere, an error is signaled.  Note
  850.      that this function ignores whether the region is active.
  851.  
  852.  - Function: region-exists-p
  853.      This function is non-`nil' if the region exists.  If active regions
  854.      are in use (i.e. `zmacs-regions' is true), this means that the
  855.      region is active.  Otherwise, this means that the user has pushed
  856.      a mark in this buffer at some point in the past.  If this function
  857.      returns `nil', a function that uses the `r' interactive
  858.      specification will cause an error when called interactively.
  859.  
  860.  - Function: region-active-p
  861.      If `zmacs-regions' is true, this is equivalent to
  862.      `region-exists-p'.  Otherwise, this function always returns false.
  863.      This function is used by commands such as
  864.      `fill-paragraph-or-region' and `capitalize-region-or-word', which
  865.      operate either on the active region or on something else (e.g. the
  866.      word or paragraph at point).
  867.  
  868.  - Variable: zmacs-region-stays
  869.      If a command sets this variable to true, the currently active
  870.      region will remain activated when the command finishes. (Normally
  871.      the region is deactivated when each command terminates.) If
  872.      ZMACS-REGIONS is false, however, this has no effect.  Under normal
  873.      circumstances, you do not need to set this; use the interactive
  874.      specification `_' instead, if you want the region to remain active.
  875.  
  876.  - Function: zmacs-activate-region
  877.      This function activates the region in the current buffer (this is
  878.      equivalent to activating the current buffer's mark).  This will
  879.      normally also highlight the text in the active region and set
  880.      ZMACS-REGION-STAYS to `t'. (If ZMACS-REGIONS is false, however,
  881.      this function has no effect.)
  882.  
  883.  - Function: zmacs-deactivate-region
  884.      This function deactivates the region in the current buffer (this is
  885.      equivalent to deactivating the current buffer's mark).  This will
  886.      normally also unhighlight the text in the active region and set
  887.      ZMACS-REGION-STAYS to `nil'. (If ZMACS-REGIONS is false, however,
  888.      this function has no effect.)
  889.  
  890.  - Function: zmacs-update-region
  891.      This function updates the active region, if it's currently active.
  892.      (If there is no active region, this function does nothing.) This
  893.      has the effect of updating the highlighting on the text in the
  894.      region; but you should never need to call this except under rather
  895.      strange circumstances.  The command loop automatically calls it
  896.      when appropriate.  Calling this function will call the hook
  897.      `zmacs-update-region-hook', if the region is active.
  898.  
  899.  - Variable: zmacs-activate-region-hook
  900.      This normal hook is called when a region becomes active. (Usually
  901.      this happens as a result of a command that activates the region,
  902.      such as `set-mark-command', `activate-region', or
  903.      `exchange-point-and-mark'.) Note that calling
  904.      `zmacs-activate-region' will call this hook, even if the region is
  905.      already active.  If ZMACS-REGIONS is false, however, this hook
  906.      will never get called under any circumstances.
  907.  
  908.  - Variable: zmacs-deactivate-region-hook
  909.      This normal hook is called when an active region becomes inactive.
  910.      (Calling `zmacs-deactivate-region' when the region is inactive will
  911.      *not* cause this hook to be called.)  If ZMACS-REGIONS is false,
  912.      this hook will never get called.
  913.  
  914.  - Variable: zmacs-update-region-hook
  915.      This normal hook is called when an active region is "updated" by
  916.      `zmacs-update-region'.  This normally gets called at the end of
  917.      each command that sets ZMACS-REGION-STAYS to `t', indicating that
  918.      the region should remain activated.  The motion commands do this.
  919.  
  920. 
  921. File: lispref.info,  Node: Text,  Next: Searching and Matching,  Prev: Markers,  Up: Top
  922.  
  923. Text
  924. ****
  925.  
  926.    This chapter describes the functions that deal with the text in a
  927. buffer.  Most examine, insert, or delete text in the current buffer,
  928. often in the vicinity of point.  Many are interactive.  All the
  929. functions that change the text provide for undoing the changes (*note
  930. Undo::.).
  931.  
  932.    Many text-related functions operate on a region of text defined by
  933. two buffer positions passed in arguments named START and END.  These
  934. arguments should be either markers (*note Markers::.) or numeric
  935. character positions (*note Positions::.).  The order of these arguments
  936. does not matter; it is all right for START to be the end of the region
  937. and END the beginning.  For example, `(delete-region 1 10)' and
  938. `(delete-region 10 1)' are equivalent.  An `args-out-of-range' error is
  939. signaled if either START or END is outside the accessible portion of
  940. the buffer.  In an interactive call, point and the mark are used for
  941. these arguments.
  942.  
  943.    Throughout this chapter, "text" refers to the characters in the
  944. buffer, together with their properties (when relevant).
  945.  
  946. * Menu:
  947.  
  948. * Near Point::       Examining text in the vicinity of point.
  949. * Buffer Contents::  Examining text in a general fashion.
  950. * Comparing Text::   Comparing substrings of buffers.
  951. * Insertion::        Adding new text to a buffer.
  952. * Commands for Insertion::  User-level commands to insert text.
  953. * Deletion::         Removing text from a buffer.
  954. * User-Level Deletion::     User-level commands to delete text.
  955. * The Kill Ring::    Where removed text sometimes is saved for later use.
  956. * Undo::             Undoing changes to the text of a buffer.
  957. * Maintaining Undo:: How to enable and disable undo information.
  958.             How to control how much information is kept.
  959. * Filling::          Functions for explicit filling.
  960. * Margins::          How to specify margins for filling commands.
  961. * Auto Filling::     How auto-fill mode is implemented to break lines.
  962. * Sorting::          Functions for sorting parts of the buffer.
  963. * Columns::          Computing horizontal positions, and using them.
  964. * Indentation::      Functions to insert or adjust indentation.
  965. * Case Changes::     Case conversion of parts of the buffer.
  966. * Text Properties::  Assigning Lisp property lists to text characters.
  967. * Substitution::     Replacing a given character wherever it appears.
  968. * Registers::        How registers are implemented.  Accessing the text or
  969.                        position stored in a register.
  970. * Transposition::    Swapping two portions of a buffer.
  971. * Change Hooks::     Supplying functions to be run when text is changed.
  972.  
  973. 
  974. File: lispref.info,  Node: Near Point,  Next: Buffer Contents,  Up: Text
  975.  
  976. Examining Text Near Point
  977. =========================
  978.  
  979.    Many functions are provided to look at the characters around point.
  980. Several simple functions are described here.  See also `looking-at' in
  981. *Note Regexp Search::.
  982.  
  983.    Many of these functions take an optional BUFFER argument.  In all
  984. such cases, the current buffer will be used if this argument is
  985. omitted. (In FSF Emacs, and earlier versions of XEmacs, these functions
  986. usually did not have these optional BUFFER arguments and always
  987. operated on the current buffer.)
  988.  
  989.  - Function: char-after POSITION &optional BUFFER
  990.      This function returns the character in the buffer at (i.e.,
  991.      immediately after) position POSITION.  If POSITION is out of range
  992.      for this purpose, either before the beginning of the buffer, or at
  993.      or beyond the end, then the value is `nil'.  If optional argument
  994.      BUFFER is `nil', the current buffer is assumed.
  995.  
  996.      In the following example, assume that the first character in the
  997.      buffer is `@':
  998.  
  999.           (char-to-string (char-after 1))
  1000.                => "@"
  1001.  
  1002.  - Function: following-char &optional BUFFER
  1003.      This function returns the character following point in the buffer.
  1004.      This is similar to `(char-after (point))'.  However, if point is at
  1005.      the end of the buffer, then the result of `following-char' is 0.
  1006.      If optional argument BUFFER is `nil', the current buffer is
  1007.      assumed.
  1008.  
  1009.      Remember that point is always between characters, and the terminal
  1010.      cursor normally appears over the character following point.
  1011.      Therefore, the character returned by `following-char' is the
  1012.      character the cursor is over.
  1013.  
  1014.      In this example, point is between the `a' and the `c'.
  1015.  
  1016.           ---------- Buffer: foo ----------
  1017.           Gentlemen may cry ``Pea-!-ce! Peace!,''
  1018.           but there is no peace.
  1019.           ---------- Buffer: foo ----------
  1020.           
  1021.           (char-to-string (preceding-char))
  1022.                => "a"
  1023.           (char-to-string (following-char))
  1024.                => "c"
  1025.  
  1026.  - Function: preceding-char &optional BUFFER
  1027.      This function returns the character preceding point in the buffer.
  1028.      See above, under `following-char', for an example.  If point is at
  1029.      the beginning of the buffer, `preceding-char' returns 0.  If
  1030.      optional argument BUFFER is `nil', the current buffer is assumed.
  1031.  
  1032.  - Function: bobp &optional BUFFER
  1033.      This function returns `t' if point is at the beginning of the
  1034.      buffer.  If narrowing is in effect, this means the beginning of the
  1035.      accessible portion of the text.  If optional argument BUFFER is
  1036.      `nil', the current buffer is assumed.  See also `point-min' in
  1037.      *Note Point::.
  1038.  
  1039.  - Function: eobp &optional BUFFER
  1040.      This function returns `t' if point is at the end of the buffer.
  1041.      If narrowing is in effect, this means the end of accessible
  1042.      portion of the text.  If optional argument BUFFER is `nil', the
  1043.      current buffer is assumed.  See also `point-max' in *Note Point::.
  1044.  
  1045.  - Function: bolp &optional BUFFER
  1046.      This function returns `t' if point is at the beginning of a line.
  1047.      If optional argument BUFFER is `nil', the current buffer is
  1048.      assumed.  *Note Text Lines::.  The beginning of the buffer (or its
  1049.      accessible portion) always counts as the beginning of a line.
  1050.  
  1051.  - Function: eolp &optional BUFFER
  1052.      This function returns `t' if point is at the end of a line.  The
  1053.      end of the buffer is always considered the end of a line.  If
  1054.      optional argument BUFFER is `nil', the current buffer is assumed.
  1055.      The end of the buffer (or of its accessible portion) is always
  1056.      considered the end of a line.
  1057.  
  1058. 
  1059. File: lispref.info,  Node: Buffer Contents,  Next: Comparing Text,  Prev: Near Point,  Up: Text
  1060.  
  1061. Examining Buffer Contents
  1062. =========================
  1063.  
  1064.    This section describes two functions that allow a Lisp program to
  1065. convert any portion of the text in the buffer into a string.
  1066.  
  1067.  - Function: buffer-substring START END &optional BUFFER
  1068.  - Function: buffer-string START END &optional BUFFER
  1069.      These functions are equivalent and return a string containing a
  1070.      copy of the text of the region defined by positions START and END
  1071.      in the buffer.  If the arguments are not positions in the
  1072.      accessible portion of the buffer, `buffer-substring' signals an
  1073.      `args-out-of-range' error.  If optional argument BUFFER is `nil',
  1074.      the current buffer is assumed.
  1075.  
  1076.      If the region delineated by START and END contains duplicable
  1077.      extents, they will be remembered in the string.  *Note Duplicable
  1078.      Extents::.
  1079.  
  1080.      It is not necessary for START to be less than END; the arguments
  1081.      can be given in either order.  But most often the smaller argument
  1082.      is written first.
  1083.  
  1084.           ---------- Buffer: foo ----------
  1085.           This is the contents of buffer foo
  1086.           
  1087.           ---------- Buffer: foo ----------
  1088.           
  1089.           (buffer-substring 1 10)
  1090.           => "This is t"
  1091.           (buffer-substring (point-max) 10)
  1092.           => "he contents of buffer foo
  1093.           "
  1094.  
  1095. 
  1096. File: lispref.info,  Node: Comparing Text,  Next: Insertion,  Prev: Buffer Contents,  Up: Text
  1097.  
  1098. Comparing Text
  1099. ==============
  1100.  
  1101.    This function lets you compare portions of the text in a buffer,
  1102. without copying them into strings first.
  1103.  
  1104.  - Function: compare-buffer-substrings BUFFER1 START1 END1 BUFFER2
  1105.           START2 END2
  1106.      This function lets you compare two substrings of the same buffer
  1107.      or two different buffers.  The first three arguments specify one
  1108.      substring, giving a buffer and two positions within the buffer.
  1109.      The last three arguments specify the other substring in the same
  1110.      way.  You can use `nil' for BUFFER1, BUFFER2, or both to stand for
  1111.      the current buffer.
  1112.  
  1113.      The value is negative if the first substring is less, positive if
  1114.      the first is greater, and zero if they are equal.  The absolute
  1115.      value of the result is one plus the index of the first differing
  1116.      characters within the substrings.
  1117.  
  1118.      This function ignores case when comparing characters if
  1119.      `case-fold-search' is non-`nil'.  It always ignores text
  1120.      properties.
  1121.  
  1122.      Suppose the current buffer contains the text `foobarbar
  1123.      haha!rara!'; then in this example the two substrings are `rbar '
  1124.      and `rara!'.  The value is 2 because the first substring is greater
  1125.      at the second character.
  1126.  
  1127.           (compare-buffer-substring nil 6 11 nil 16 21)
  1128.                => 2
  1129.  
  1130.